#ifndef RESOURCEMANAGER_H
#define RESOURCEMANAGER_H

#include "TriMesh.h"
#include <QString>
#include <map>

class ResourceManager
{


    ResourceManager();
    ResourceManager(ResourceManager const&);              // Don't Implement
    void operator=(ResourceManager const&); // Don't implement
public:

    std::map<QString,TriMesh*> resources;

    static ResourceManager* getInstance()
    {
        static ResourceManager instance; // Guaranteed to be destroyed.
                              // Instantiated on first use.
        return &instance;
    }

    void Delete(QString name)
    {
        map<QString,TriMesh*>::iterator it = resources.find(name);
        if(it != resources.end())
        {
            it->second->numReferences--;
            if(it->second->numReferences == 0)
            {
                delete(it->second);
                resources.erase(it);
            }
        }
    }

    TriMesh* Get(const QString &name);

};

#endif // RESOURCEMANAGER_H

